package com.ming.springcloud.student.service;

import java.util.List;
import java.util.Optional;
import javax.annotation.Resource;
import com.ming.springcloud.student.pojo.StudentEntity;
import com.ming.springcloud.student.dao.IStudendDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

@Service("studentService")
public class StudentServiceImpl implements IStudentService {

	@Resource
	@Autowired
	private IStudendDao studendDao;
	
	@Override
	public Page<StudentEntity> findAllServers(Pageable pageable) {
		// TODO Auto-generated method stub
		return studendDao.findAll(pageable);
	}

	@Override
	public void delete(Integer id) {
		// TODO Auto-generated method stub
		studendDao.deleteById(id);
	}


	@Override
	public void save(StudentEntity student) {
		// TODO Auto-generated method stub
		studendDao.save(student);
	}

	@Override
	public Optional<StudentEntity> findUserById(Integer id) {
		// TODO Auto-generated method stub
		return studendDao.findById(id);
	}

	@Override
	public void edit(StudentEntity student) {
		// TODO Auto-generated method stub
		studendDao.save(student);
	}

	@Override
	public List<StudentEntity> findServerByNameLike(String name) {
		// TODO Auto-generated method stub
		return studendDao.findBystuNameLike("%"+name+"%");
	}

	@Override
	public List<StudentEntity> findAll() {
		return studendDao.findAll();
	}

}
